<template>
	<view>
		<view class="van_top">
			<van-nav-bar title="设置" left-arrow @click-left="onClickLeft" />
		</view>
		<view class="content" style="padding-top: 24rpx;">
			<van-cell-group inset>
				<van-cell title="用户隐私协议" is-link url="/packageA/pages/agreement/agreement?type=0" />
				<van-cell title="修改密码" is-link url="/packageA/pages/changePw/changePw" v-if="permissionStatus != '4'"/>
				<van-cell title="关于我们" is-link url="/packageA/pages/about/about?type=2" />
			</van-cell-group>
			<view class="btnBox" v-if="permissionStatus != '4'">
				<view class="btn" @click="logout">
					退出登录
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapGetters } from 'vuex';
	import { removeToken } from '@/utils/auth'
	export default {
		data() {
			return {

			};
		},
		computed: {
			...mapGetters('user', ['permissionStatus'])
		},
		async onShow() {
			await this.$store.dispatch('user/getUserStatus');
			if(this.permissionStatus == '4') {
				removeToken();
			}
		},
		methods: {
			onClickLeft() {
				uni.switchTab({ url: '/pages/my/my' });
			},
			logout() {
				uni.showModal({
					title: '提示',
					content: '确定退出登录吗？',
					success: async (res) => {
						if (res.confirm) {
							console.log('用户点击确定');
							let res1 = await this.$store.dispatch('user/userLogout');
							if (res1.code === 200) {
								uni.redirectTo({ url: '/pages/login/login' });
							}
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}
		},
	}
</script>
<style>
	page {
		background: #f5f5f5;
	}
</style>
<style lang="scss" scoped>
	/deep/ .van-cell-group--inset {
		margin: 0 24rpx !important;
	}

	.btnBox {
		padding: 0 24rpx;
		width: 750rpx;
		box-sizing: border-box;
		margin-top: 48rpx;

		.btn {
			width: 100%;
			background-color: #fff;
			color: #333;
			height: 76rpx;
			line-height: 76rpx;
			text-align: center;
		}
	}
</style>